Telegram Group & Telegram Channel
Что выведет этот код на Python?


x = [1, 2, 3]
y = x
x += [4]

print(x)
print(y)


🔢 Варианты ответа:

A)

[1, 2, 3]


B)

[1, 2, 3, 4]


C)

[1, 2, 3, 4]


D)

[1, 2, 3]


Правильный ответ: B

💡 Почему?
-
x = [1, 2, 3] и y = x — ссылка на один и тот же список.
-
x += [4] модифицирует список на месте.
- Поэтому
y тоже видит изменение.
🧠 Подвох — в
+=, который работает не как x = x + [...].



tg-me.com/python_job_interview/1072
Create:
Last Update:

Что выведет этот код на Python?


x = [1, 2, 3]
y = x
x += [4]

print(x)
print(y)


🔢 Варианты ответа:

A)

[1, 2, 3]


B)

[1, 2, 3, 4]


C)

[1, 2, 3, 4]


D)

[1, 2, 3]


Правильный ответ: B

💡 Почему?
-
x = [1, 2, 3] и y = x — ссылка на один и тот же список.
-
x += [4] модифицирует список на месте.
- Поэтому
y тоже видит изменение.
🧠 Подвох — в
+=, который работает не как x = x + [...].

BY Python вопросы с собеседований


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_job_interview/1072

View MORE
Open in Telegram


Python вопросы с собеседований Telegram | DID YOU KNOW?

Date: |

The seemingly negative pandemic effects and resource/product shortages are encouraging and allowing organizations to innovate and change.The news of cash-rich organizations getting ready for the post-Covid growth economy is a sign of more than capital spending plans. Cash provides a cushion for risk-taking and a tool for growth.

Telegram has exploded as a hub for cybercriminals looking to buy, sell and share stolen data and hacking tools, new research shows, as the messaging app emerges as an alternative to the dark web.An investigation by cyber intelligence group Cyberint, together with the Financial Times, found a ballooning network of hackers sharing data leaks on the popular messaging platform, sometimes in channels with tens of thousands of subscribers, lured by its ease of use and light-touch moderation.Python вопросы с собеседований from in


Telegram Python вопросы с собеседований
FROM USA